﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//using Microsoft.Scripting.Hosting;
//using IronPython.Hosting;
using System.Xml.Linq;

namespace ReporterEngine
{
    public class test
    {
        public static void tt()
        {
            /// {section@name}{section}{endsection}
            
            // var resNode = sp.Parse("#property1:ascby(#prop1[#prop2=='value1'])#childs[#property2=='value1' && 2==2 || (33==3)]#property3");
            
           // sQuery q = new sQuery();

           // q.property("property1").ascby("prop1 asc,prop2 desc").childs().filter(x=>1==1).property("property3");

            //Dictionary<string, object> data = new Dictionary<string, object>();
            
            //data.Add("o", q);

            //var py = Python.CreateRuntime(AppDomain.CurrentDomain,data);

            

            //dynamic result = py.GetClrModule().Engine.Execute("2+2");

            ////dynamic result2 = py.GetClrModule().Engine.Execute("o");

            //var en = Python.CreateEngine(AppDomain.CurrentDomain);
            //var scope = en.CreateScope();

            //scope.SetVariable("o", q);

            //dynamic res3 = en.Execute("o.property(\"property1\").filter(lambda x:x.property(\"property1\") != null)", scope);

            //int ee = 12;
        }

        public static void tt2()
        {
            var template = XDocument.Load("d:\\Development\\Novitech\\ProvisionReporter\\ReporterApplication\\ReporterEngine\\data\\test1.xml");
            var cif = XDocument.Load("d:\\Development\\Novitech\\ProvisionReporter\\ReporterApplication\\ReporterEngine\\data\\cif1.xml");
            
            var args = WordReportEngine.CreateArgs();

            CIFModel cifModel = new CIFModel();

            cifModel.Parse(cif);


            args.CurrentDesign = template.Root;

            WordReportEngine re = new WordReportEngine();
            re.Model = cifModel;

            var validationResult = re.ValidateSections(template.Root.Value);

            re.Report(args);

            
        }

        public static string ttEval(string path)
        {
            var template = XDocument.Load("d:\\Development\\Novitech\\ProvisionReporter\\ReporterApplication\\ReporterEngine\\data\\test1.xml");
            var cif = XDocument.Load("d:\\Development\\Novitech\\ProvisionReporter\\ReporterApplication\\ReporterEngine\\data\\cif1.xml");

            CIFModel cifModel = new CIFModel();

            cifModel.Parse(cif);


            var result = "";

            var query = sQuery.New(cifModel);
            
            //result = PathParser.Parse("> prop1");
            //result = PathParser.Parse("> .count()");
            //o.types("Use Cases").property("property1").filter(lambda x:x.property("property1") != null)
            //68
            //result = PathParser.Parse("> .types(Use Case Model) > .members() > .distinct() > .count()");
            result = PathParser.Parse("> .types(Use Case Model) > subject > name");
            //result = PathParser.Parse("> .types(Use Cases)  > (Use Cases , \"events\" ) > property1, prop2 > .members() < ref >prop4,prop5> [ (Events) > prop5 > prop6 > .count() == 7] > .sortby(name) > propval >");

           // var cifres = cifModel.Eval(result);

            return result;          
        }
    }
}
